/*** This database script is for SQL Server 2005 / 2008 ***/

USE [ISAControl]
GO
/****** Object:  User [sapienaccess]    Script Date: 04/28/2010 15:29:45 ******/
CREATE USER [sapienaccess] FOR LOGIN [sapienaccess] WITH DEFAULT_SCHEMA=[dbo]
GO
/****** Object:  Table [dbo].[RuleInfo]    Script Date: 04/28/2010 15:29:45 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[RuleInfo](
	[ruleid] [int] NOT NULL,
	[rulename] [varchar](100) NOT NULL,
	[ruledesc] [varchar](300) NOT NULL,
	[isactive] [bit] NOT NULL,
	[setby] [varchar](50) NULL,
	[whenset] [datetime] NULL,
	[autoclear] [datetime] NULL,
 CONSTRAINT [PK_RuleInfo] PRIMARY KEY CLUSTERED 
(
	[ruleid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
CREATE UNIQUE NONCLUSTERED INDEX [IX_RuleInfoDesc] ON [dbo].[RuleInfo] 
(
	[ruledesc] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
CREATE UNIQUE NONCLUSTERED INDEX [IX_RuleInfoName] ON [dbo].[RuleInfo] 
(
	[rulename] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[PendingChanges]    Script Date: 04/28/2010 15:29:45 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[PendingChanges](
	[requestid] [int] IDENTITY(1,1) NOT NULL,
	[ruleid] [int] NOT NULL,
	[newstate] [bit] NOT NULL,
	[username] [varchar](50) NOT NULL,
	[expires] [datetime] NOT NULL,
 CONSTRAINT [PK_PendingChanges] PRIMARY KEY CLUSTERED 
(
	[requestid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Check [CK_PendingChangesExpires]    Script Date: 04/28/2010 15:29:45 ******/
ALTER TABLE [dbo].[PendingChanges]  WITH CHECK ADD  CONSTRAINT [CK_PendingChangesExpires] CHECK  (([expires]>getdate()))
GO
ALTER TABLE [dbo].[PendingChanges] CHECK CONSTRAINT [CK_PendingChangesExpires]
GO
/****** Object:  ForeignKey [FK_PendingChanges_RuleInfo]    Script Date: 04/28/2010 15:29:45 ******/
ALTER TABLE [dbo].[PendingChanges]  WITH CHECK ADD  CONSTRAINT [FK_PendingChanges_RuleInfo] FOREIGN KEY([ruleid])
REFERENCES [dbo].[RuleInfo] ([ruleid])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[PendingChanges] CHECK CONSTRAINT [FK_PendingChanges_RuleInfo]
GO
GRANT INSERT ON [dbo].[PendingChanges] TO [public]
GO
GRANT REFERENCES ON [dbo].[PendingChanges] TO [public]
GO
GRANT SELECT ON [dbo].[PendingChanges] TO [public]
GO
GRANT REFERENCES ON [dbo].[RuleInfo] TO [public]
GO
GRANT SELECT ON [dbo].[RuleInfo] TO [public]
GO
